﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Bowling.Test
{
    public class ScoreLineFormatter
    {
        private readonly Frame _frame;

        public ScoreLineFormatter(Frame frame)
        {
            _frame = frame;
        }

        private string bonusText
        {
            get { return (_frame.Bonus.HasValue) ? ", " + _frame.Bonus.Value.ToString() + " " : ""; }
        }

        private string rollText
        {
            get { return _frame.Roll1 + ((_frame.Roll2.HasValue) ? ", " + _frame.Roll2 : "") + ((_frame.Bonus.HasValue) ? "" : " "); }
        }

        public string GetScoreSheetLine()
        {
            return string.Format("#{0}) {1}{2}[{3}] => {4}",
                     _frame.FrameNumber + 1,
                     rollText,
                     bonusText,
                     _frame.Score.RollScore,
                     _frame.Score.TotalScore);
        }

    }
}
